package com.smartEdu.service.impl.app;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.springframework.stereotype.Service;

import com.smartEdu.commons.Session;
import com.smartEdu.commons.Tag_Http_Tips;
import com.smartEdu.commons.Tag_Tips;
import com.smartEdu.service.BaseService;
import com.smartEdu.utils.HttpUtil;

@Service(value="scheduleServiceImpl")
public class ScheduleServiceImpl implements BaseService{
	public String GetScheduleContent(Session sess){
		Tag_Http_Tips tips=new Tag_Http_Tips();
		HttpUtil httpUtil=new HttpUtil();
		
		HttpPost httpPost=new HttpPost(tips.URL_LOGIN);
		httpPost.setConfig(HttpUtil.GetRequestConfig());
		HttpUtil.SetHeader(httpPost,tips.HOST,tips.URL_LOGIN);
		
		httpUtil.setHttpPost(httpPost);
	    
		Map<String, String> paramMap=new HashMap<>();
//		paramMap.put("USERNAME", "130201031035");
//		paramMap.put("PASSWORD", "abc123abc");
		paramMap.put("USERNAME", "02018");
		paramMap.put("PASSWORD", "Aa123456");
		paramMap.put("USERTYPE", Tag_Tips.TEACHER);
		String result="";
		try {
			httpUtil.RequestPost(HttpUtil.SetRequestParams_default6(tips, paramMap));
			httpUtil.releaseConnection();
//			HttpGet httpGet=new HttpGet(tips.URL_MAIN_STUDENT.replace("XH", "130201031035"));
			HttpGet httpGet=new HttpGet(tips.URL_MAIN_TEACHER.replace("XH", "02018"));
			httpUtil.setHttpGet(httpGet);
			result=httpUtil.RequestGet();
			httpUtil.releaseConnection();
//			HttpGet httpGet2=new HttpGet(tips.URL_QUERY.replace("QUERY", "js_grjl.aspx?zgh=02018&xm=�¶�ΰ&gnmkdm=N122201"));
//			httpGet2.setHeader("Referer", tips.URL_MAIN_TEACHER);
//			httpUtil.setHttpGet(httpGet2);
//			result=httpUtil.RequestGet();
//			httpUtil.releaseConnection();
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		finally {
			httpUtil.closeHttpClient();
		}
		return result;
	}
}
